package eight.spring.jmx;

import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedOperationParameter;
import org.springframework.jmx.export.annotation.ManagedOperationParameters;
import org.springframework.jmx.export.annotation.ManagedResource;

@ManagedResource(objectName="liuys:name=testBean3",description="My managed bean",log=true,
	logFile="jmx.log",currencyTimeLimit=15,persistPolicy="OnUpdate",persistPeriod=200,
	persistLocation="foo",
	persistName="bar"
)
public class People {

	private String name;
	private String age;
	private boolean isSuperMan;
	
	@ManagedAttribute(defaultValue="foo",persistPeriod=300)
	public String getName() {
		return name;
	}
	
	@ManagedAttribute(description="the Name attribute",currencyTimeLimit=20,defaultValue="bar",persistPolicy="OnUpdate")
	public void setName(String name) {
		this.name = name;
	}
	
	@ManagedAttribute(description="the Age attribute",currencyTimeLimit=15)
	public String getAge() {
		return age;
	}
	public void setAge(String age) {
		this.age = age;
	}


	@ManagedOperation(description="add two numbers")
	@ManagedOperationParameters({
		@ManagedOperationParameter(name="x",description="the first number"),
		@ManagedOperationParameter(name="y",description="the second number"),
	})
	public int add(int x, int y) {
		System.out.println("Add method is invoked... The value is "+(x+y));
        return x + y;
    }

    public void dontExposeMe() {
        throw new RuntimeException();
    }
}
